package com.assessment.utils;

import java.util.Map;

import static com.assessment.utils.Constant.CODE_ERROR;
import static com.assessment.utils.Constant.CODE_SUCCESS;


public class ReturnMap {

    // 修改信息
    public static Map<String, Object> changeMap(Map<String, Object> map, Integer code, String msg) {
        return changeMap(map, code, msg, "");
    }

    // 修改信息
    public static Map<String, Object> changeMap(Map<String, Object> map, String msg, Object data) {
        return changeMap(map, CODE_SUCCESS, msg, data);
    }

    // 修改信息
    public static Map<String, Object> changeMap(Map<String, Object> map, Object data) {
        return changeMap(map, CODE_SUCCESS, "SUCCESS", data);
    }

    // 修改信息Z
    public static Map<String, Object> changeMap(Map<String, Object> map, Integer code, String msg, Object data) {
        map.put("code", code);
        map.put("msg", msg);
        map.put("data", data);
        return map;
    }

    public static void changeMapMsg(Map<String, Object> map, String msg) {
        map.put("msg", msg);
    }

    // 成功返回的map
    public static Map<String, Object> successMap() {
        return successMap("SUCCESS");
    }
    // 成功返回的map
    public static Map<String, Object> successMap(String msg) {
        return successMap(msg,"");
    }
    // 成功返回的map
    public static Map<String, Object> successMap(String msg,Object data) {
        return new OneReturn(CODE_SUCCESS,msg,data).getMap();
    }

    // 失败返回的map
    public static Map<String, Object> failedMap() {
        return failedMap("ERROR");
    }
    // 失败返回的map
    public static Map<String, Object> failedMap(String msg) {
        return failedMap(msg,"");
    }
    // 失败返回的map
    public static Map<String, Object> failedMap(String msg,Object data) {
        return new OneReturn(CODE_ERROR,msg,data).getMap();
    }

    // 失败返回的map
    public static Map<String, Object> failedMap(Map<String, Object> map, String msg) {
        return changeMap(map, CODE_ERROR, msg, "");
    }

    // 失败返回的map
    public static Map<String, Object> failedMap(Map<String, Object> map, String msg, Object data) {
        return changeMap(map, CODE_ERROR, msg, data);
    }

    // 失败返回的map
    public static Map<String, Object> failedMap(Map<String, Object> map, Object data) {
        return changeMap(map, CODE_ERROR, "ERROR", data);
    }

}

